//
//  MyTransportOrderDetailOtherCell.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2021/3/12.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "MyTransportOrderDetailOtherCell.h"

@interface MyTransportOrderDetailOtherCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *contentLab;

@end

@implementation MyTransportOrderDetailOtherCell

+ (instancetype)MyTransportOrderDetailOtherCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"MyTransportOrderDetailOtherCell";
    MyTransportOrderDetailOtherCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[MyTransportOrderDetailOtherCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = Color_backgroundColor;
        
        self.bgView = [UIView new];
        self.bgView.backgroundColor = HexColor(0xffffff);
        self.bgView.layer.cornerRadius = 6;
        [self.contentView addSubview:self.bgView];
        
        self.titleLab = [UILabel new];
        self.titleLab.textColor = HexColor(0x9C9DB3);
        self.titleLab.font = [UIFont systemFontOfSize:12];
        [self.bgView addSubview:self.titleLab];
        
        self.contentLab = [UILabel new];
        self.contentLab.textColor = HexColor(0x2B2C44);
        self.contentLab.font = [UIFont systemFontOfSize:14];
        self.contentLab.numberOfLines = 0;
        [self.bgView addSubview:self.contentLab];
    }
    return self;
}

-(void)setTitleText:(NSString *)titleText {
    _titleText = titleText;
    self.titleLab.text = titleText;
}

-(void)setContentText:(NSString *)contentText {
    _contentText = contentText;
    [self configUI];
}

- (void)configUI {
    self.bgView.nim_left = 15;
    self.bgView.nim_top = 0;
    self.bgView.nim_width = ScreenW - 30;
    
    self.titleLab.frame = CGRectMake(15, 10, self.bgView.nim_width - 30, 13);
    
    self.contentLab.text = self.contentText;
    self.contentLab.nim_left = 15;
    self.contentLab.nim_top = self.titleLab.nim_bottom + 5;
    self.contentLab.nim_width = self.bgView.nim_width - 30;
    [self.contentLab sizeToFit];
    self.contentLab.nim_width = self.bgView.nim_width - 30;
    
    self.bgView.nim_height = self.contentLab.nim_bottom + 10;
    self.height = self.bgView.nim_bottom;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
